<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Jedrzej\Pimpable\PimpableTrait;
use Illuminate\Database\Eloquent\SoftDeletes;

class OrderEconomize extends Model
{
    use HasFactory;
    use PimpableTrait;
    use SoftDeletes;

    /**
     * 表中的类型状态
     */
    //订单类型
    public $orderTypeEnum = [
        'onLine' => '线上订单',
        'offline' => '线下订单'
    ];


    /**
     * 可搜索字段
     */
    public $searchable = [
        'order_id',
        'user_id',
        'order_type'
    ];

    /**
     * 可批量赋值字段 无
     */


    /**
     * 可排序字段
     */
    public $sortable = ['created_at', 'id'];

    /**
     * 默认排序字段
     */
    protected $defaultSortCriteria = ['id,desc'];

    /**
     * 关联的订单
     */
    function order(){
        return $this->belongsTo(Order::class,'order_id','id');
    }

    /**
     * 关联的用户
     */
    function user(){
        return $this->belongsTo(User::class,'user_id','id');
    }
}
